#ifndef YEP_UI_LABEL_HPP
#define YEP_UI_LABEL_HPP

#include "Widget.hpp"
#include <string>
namespace yep
{
    /**
     * @brief A static text on screen.
     **/
    class Label : public Widget
    {
    public:
        /**
         * @brief Called when it needs to be redrawn.
         **/
        void onDraw(SDL_Surface * screen)
        {
            style->drawLabel(screen, _text, isFocused(), getAbsolutePosition(), getAbsoluteArea(), getTextColor(), getBackgroundColor() );
        }

        /**
         * @brief Constructor.
         **/
        Label(const string &t=""):_text(t)
        {
            autoResize();
        }

        /**
         * @brief Returns the _text.
         **/
        const string &text() const
        {
            return _text;
        }

        /**
         * @brief Changes the text.
         **/
        void text(const string &value)
        {
            _text = value;
            autoResize();
        }

        /**
         * @brief Enlarge the size to fit text.
         **/
        virtual void autoResize()
        {
            Uint16 w, h;
            style->labelArea(_text, w, h);
            Rect newArea(getRect());
            if(newArea.w() < w)
                newArea.setW(w);
            if(newArea.h() < h)
                newArea.setH(h);
            setRect(newArea);
        }
    private:
        string _text;
    };
}

#endif // YEP_UI_LABEL_HPP

